﻿using System;
using System.Windows.Forms;
using System.Collections.Generic;
using System.Text;
using System.Drawing;
using Acid.Math;
namespace Acid.Interaction
{
    /// <summary>
    /// Class Responsible for tracking user input.
    /// </summary>
    public class Tracker
    {
        private Point oldPoint;
       
        private Point newPoint;

        public Tracker()
        {
            this.oldPoint = new Point(0, 0);
            
            this.newPoint = new Point(0, 0);
        }

        /// <summary>
        /// Typically called during a mouse down event to fix the position correctly. 
        /// </summary>
        /// <param name="point"></param>
        /// <returns></returns>
        public void Reset(Point point)
        {
            this.oldPoint = point;

            this.newPoint = point;
        }
        /// <summary>
        /// Updates Position and returns a Un Normalized Vector2 representing the change.
        /// </summary>
        /// <param name="point"></param>
        /// <returns></returns>
        public Vector2 Update(Point point)
        {
            Vector2 result = new Vector2(point.X - oldPoint.X,
                                         point.Y - oldPoint.Y);
            
            this.oldPoint = newPoint;
            
            this.newPoint = point;

            return result;
        }
    }
}
